<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <f:view>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Entidades</title>
        <link type="text/css" href="../common/css/redmond/jquery-ui-1.8.23.custom.css" rel="stylesheet" />
        <link type="text/css" href="../common/css/administrar.css" rel="stylesheet" />
	<script type="text/javascript" src="../common/js/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="../common/js/jquery.ui.all.js"></script>
	<script type="text/javascript" src="../common/js/jquery.layout.js"></script>
        <script type="text/javascript" src="../common/js/jquery-ui-1.8.6.custom.min.js"></script>
        <script type="text/javascript" src="../common/js/calendarioui-es.js"></script>
        <script type="text/javascript" src="../common/js/jquery.dateentry.js"></script>
        <script type="text/javascript" src="../common/js/facturas.js"></script>
        <script type="text/javascript" src="../common/js/rips.js"></script>
        <script type="text/javascript" src="../common/js/jquery.contextmenu.r2.js"></script>
        <script type="text/javascript" src="../common/js/jquery.validate.js"></script>

        <style type="text/css" title="currentStyle">
			@import "../common/css/demo_page.css";
			/*@import "../common/css/demo_table.css";*/
                        @import "../common/css/demo_table_jui.css";
		</style>

        <script type="text/javascript" language="javascript" src="../common/js/jquery.dataTables.js"></script>

        <script>

            var asInitVals = new Array();

            $(document).ready(function() {
			var oTable = $('#example').dataTable( {
                                        "sPaginationType": "full_numbers",
                                        "bJQueryUI": true,
					"bProcessing": true,
					"bServerSide": true,
					"sAjaxSource": "/salus/FacturasServlet",
                                        "oLanguage": {
                                                        "sLengthMenu": "Mostrar _MENU_ registros por Pagina",
                                                        "sZeroRecords": "Opps - No se encontraron datos",
                                                        "sInfo": "Mostrando _START_ a _END_ de _TOTAL_ registros",
                                                        "sInfoEmpty": "Mostrando 0 a 0 de 0 registros",
                                                        "sInfoFiltered": "(filtered from _MAX_ total records)"
                                                    }

				} );



                                $("tfoot input").keyup( function () {
                                        /* Filter on the column (the index) of this element */
                                        oTable.fnFilter( this.value, $("tfoot input").index(this) );
                                } );



                                /*
                                 * Support functions to provide a little bit of 'user friendlyness' to the textboxes in
                                 * the footer
                                 */
                                $("tfoot input").each( function (i) {
                                        asInitVals[i] = this.value;
                                } );

                                $("tfoot input").focus( function () {
                                        if ( this.className == "search_init" )
                                        {
                                                this.className = "";
                                                this.value = "";
                                        }
                                } );

                                $("tfoot input").blur( function (i) {
                                        if ( this.value == "" )
                                        {
                                                this.className = "search_init";
                                                this.value = asInitVals[$("tfoot input").index(this)];
                                        }
                                } );


                                /* Add a click handler to the rows - this could be used as a callback */
                                $("#example tbody").dblclick(function(event) {
                                        $(oTable.fnSettings().aoData).each(function (){
                                                $(this.nTr).removeClass('row_selected');
                                        });
                                        $(event.target.parentNode).addClass('row_selected');

                                        var anSelected = fnGetSelected( oTable );
                                        //oTable.fnDeleteRow( anSelected[0] );
                                        var dato=anSelected[0].cells;
                                        //alert(dato[0].innerHTML);

                                        mostrarOpcionesFactura(dato[0].innerHTML,dato[1].innerHTML)



                                });
                                       
                               



                                /* Add a click handler for the delete row */
                                $('#delete').click( function() {
                                        var anSelected = fnGetSelected( oTable );
                                        //oTable.fnDeleteRow( anSelected[0] );
                                        var dato=anSelected[0].cells;
                                        alert(dato[0].innerHTML);
                                } );



			} );


                        /* Get the rows which are currently selected */
                        function fnGetSelected( oTableLocal )
                        {
                                var aReturn = new Array();
                                var aTrs = oTableLocal.fnGetNodes();

                                for ( var i=0 ; i &lt; aTrs.length ; i++ )
                                {
                                        if ( $(aTrs[i]).hasClass('row_selected') )
                                        {
                                                aReturn.push( aTrs[i] );
                                        }
                                }
                                return aReturn;
                        }






        </script>



    </head>
        <body>
                        
                <div id="dynamic">
                    <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
                        <thead>
                            <tr>
                                <th width="5%">Consec</th>
                                <th width="13%">N&uacute;mero Factura</th>
                                <th width="12%">Identif Paciente</th>
                                <th width="45%">Nombre paciente</th>
                                <th width="25%">Fecha</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td colspan="3" class="dataTables_empty">Loading data from server</td>
                            </tr>
                        </tbody>

                        <tfoot>
                            <tr>
                                <th>&nbsp;</th>
                                <th><input size="20" type="text" name="search_factura" value="Numero Factura" class="search_init" /></th>
                                <th><input type="text" name="search_ident" value="Numero Identif" class="search_init" /></th>
                                <th><input type="text" name="search_paciente" value="Nombre Paciente" class="search_init" /></th>
                                <th><input type="text" name="search_fecha" value="Fecha Factura" class="search_init" /></th>
                            </tr>
                        </tfoot>


                       
                    </table>
                </div>


            <div id="dialogo-opc-factura" style="display: none">
                <center>
                <button id="facturaEditar">Editar</button>
                <button id="facturaAnular">Anular</button>
                <button id="facturaRips">Rips</button>
                <button id="facturaImprimir">Imprimir</button>
                </center>
                <input type="text" id="idFacturaGestion"/>
                <input type="text" id="idservicio" value=""/>
            </div>

            <!--dialogo rips-->
            <div id="dialogoRips" style="display: none" title="RIPS">
            </div>


        </body>
         </f:view>
</html>